%page inherit Index;

%page route "faq";
%using System;
%using NetFluid;
%using MongoDB.Driver.Builders;

%override Body
    
    %if(Request.ContainsKey("question"))
        % var from = Site.MainAddress;
        % if( Request.ContainsKey("notify") && session("User")!=null )
            %from = session("User").Mail;
        % end if
        %Mailer.Send(Site.MainAddress,"NetFluid FAQ",Request["question"],Site.MainAddress, from,from);
    %end if
    <div class="content" style="background-color:{%rand_color()%};">
        <h1>FAQ</h1>
		%foreach(var faq in Database.News.Find(Query.EQ("Category", "FAQ")))
			<div class="faq">
				<div class="faq-question" id="{%faq.Title%}">
					<h3>{%faq.Title%}</h3>
				</div>
				<div class="faq-answer">
					{%faq.Body%}
				</div>
			</div>
    	%end foreach
        <form action="/faq" method="post">
            <h2>Send new</h2>
            <p>
                <textarea name="question" cols="64" rows="7"></textarea>
                % if(session("User")!=null)
                    <p>
                        <input type="checkbox" value="notify" name="notify"/><label>Notify me on answer</label>
                    </p>
                %else
                    <p>Sign up to be notified on answer</p>
                %end if
            </p>
            <input type="submit" value="Send" />
        </form>
    </div>
%end override